import { getJSON } from "./ajax/index.js";
import { SUC_CODE, TIME_OUT } from "./config.js";

function getData(url, options) {
  return getJSON(url, {
    timeoutTime: TIME_OUT,
    ...options,
  })
    .then((res) => {
      if (res.code === SUC_CODE) {
        return res.data;
      } else {
        throw new Error(`error ${res.code}`);
      }
    })
    .catch((err) => console.log(err));
}

export { getData };
